package hibernate_basic.Persistence.comment_persitence;


import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

/**
 * @author Administrator
 * @create 2018-12-30 16:50
 * @desc 存储使用注解的持久化对象
 **/
public class StoragePersistence {

    public static void main(String []args){

        Configuration config=new Configuration();
        config.configure("hibernate_basic/config/config_comment/hibernate.cfg.xml");

        SessionFactory sessfac=config.buildSessionFactory();//构建SessionFacatory

        Session session=sessfac.openSession();//打开session会话

        Transaction tion=session.beginTransaction();//开始事务

        Person son=new Person();
        son.setName("黄彪");
        son.setAge(36);
        son.setHeight(185);
        son.setWeight(65);

        session.save(son);
        tion.commit();
        session.close();


        System.out.println("end");
    }

}
